﻿using System.Linq;
using WalkingTec.Mvvm.Core;

namespace ReaWTM.LayuiHelper.Extensions
{
	public static class GridActionExtensions
	{
		public static GridAction MakeRowScriptButton<T, V>(this IBasePagedListVM<T, V> self, string funcName, string btnText, string buttonId = null,
			string promptMessage = null, string iconCls = null, string btnClass = null) where T : TopBasePoco where V : ISearcher
		{
			return new GridAction
			{
				ButtonId = buttonId,
				Name = btnText,
				ControllerName = "RowScriptButton",
				ActionName = "JsBtn",
				ParameterType = GridActionParameterTypesEnum.SingleId,
				IconCls = iconCls,
				ShowInRow = true,
				ShowDialog = false,
				HideOnToolBar = true,
				PromptMessage = promptMessage,
				ButtonClass = btnClass,
				OnClickFunc = funcName
			};
		}

		public static GridAction MakeRowCopyButton<T, V>(this IBasePagedListVM<T, V> self,string btnText = "复制", string buttonId = null,
	string promptMessage = null, string iconCls = null, string btnClass = null) where T : TopBasePoco where V : ISearcher
		{
			return new GridAction
			{
				ButtonId = buttonId,
				Name = btnText,
				ControllerName = "RowScriptButton",
				ActionName = "JsBtn",
				ParameterType = GridActionParameterTypesEnum.SingleId,
				IconCls = iconCls,
				ShowInRow = true,
				ShowDialog = false,
				HideOnToolBar = true,
				PromptMessage = promptMessage,
				ButtonClass = btnClass,
				OnClickFunc = "wtm.table_CopyGridRow"
			};
		}
	}
}